<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>

<script type="text/javascript" charset="utf-8">
	
	var datagrid;//列表对象
	var number = '${param.number}';//判断是否为多选
		
	var bianHao_inputName = '${param.bianHao_inputName}';
	var mingCheng_inputName = '${param.mingCheng_inputName}';

	/**
	*加载列表
	**/		
    $(function loadDatagrid() {
    	$('#selectInput').focus();

		var single = true;

		datagrid = $('#datagrid').datagrid({
			url : 'userAction!datagrid.action?zhuangTai=11',
			title : '',
			pagination : true,
			pageSize : 40,
			pageList : [ 10, 20, 30, 40 ],
			fit : true,
			fitColumns : true,
			nowrap : false,
			border : false,
			idField : 'bianHao',
			singleSelect : single,
			checkOnSelect : false,
			selectOnCheck : true,
			columns : [ [ //字段定义
	   		{
				title : '<s:text name="userID"></s:text>',
				field : 'userID',
				width : 50,
				sortable : true,
				checkbox : true
			}
			,{
				title : '<s:text name="userName"></s:text>',
				field : 'userName',
				width : 100
			}
			,{
				title : '<s:text name="组织机构"></s:text>',
				field : 'zuZhiJGMC',
				width : 100
			}
			,{
				title : '<s:text name="zhiCheng"></s:text>',
				field : 'zhiChengMCs',
				width : 100
			}
			] ]
			,toolbar : [ {
				text : '<s:text name="select"></s:text>',
				iconCls : 'icon-edit',
				handler : function() {
					select();
				}
			}, '-']
			/*{
				text : '<s:text name="clean"></s:text>',
				iconCls : 'icon-cancel',
				handler : function() {
					clean();
				}
			}, '-']*/
		});
	});
	
	/**
	* 选择
	**/
	function select() {
		var ddd = share.data('userSelectDialog');
		var dd = share.data('flowTaskNodeUserDialog');
		//var f = d.find('form');
		var f = share.data('form');
		var rows = datagrid.datagrid('getChecked');//获取选中行
		if(rows.length==1){
			$.ajax({ //加载任务基本信息
				url : 'flowTaskNodeAction!updateUser.action',
				data : {ftn_ID:'${ftn_ID}',ftn_UserCode:rows[0].userID},
				dataType : "html",
				success: function(d) {
					var json = $.parseJSON(d);
					try{
						if (json.success) {
							ddd.dialog('close');
							dd.dialog('close');
						}
						parent.dagong.messagerShow({
							msg : json.msg,
							title : '<s:text name="prompt"></s:text>'
						});
					}catch(e){alert(e.message)}
		        }
			});
		} else if (rows.length > 1) {
			parent.dagong.messagerAlert('<s:text name="prompt"></s:text>', '<s:text name="PleaseChooseOnlyOneData"></s:text>', 'error');
		} else {
			parent.dagong.messagerAlert('<s:text name="prompt"></s:text>', '<s:text name="PleaseSelectARecord"></s:text>', 'error');
		}
		userName.focus();
	}
	
	/**
	* 提交查询
	**/
	function _search() {
		datagrid.datagrid('load', dagong.serializeObject($('#searchForm')));
	}
	
	/**
	* 清空查询条件
	**/
	function cleanSearch() {
	//	datagrid.datagrid('load', {});
	//	$('#searchForm input').val('');
		clean();
	}
	
	/**
	* 清除数据
	**/
	function clean() {
		var d = share.data('userSelectDialog');
		var f = share.data('form');
		var userID = f.find('input[name=userID]');
		var userName = f.find('input[name=userName]');
		
		if(bianHao_inputName!=undefined&&bianHao_inputName!=''&&bianHao_inputName!=null){
			userID =  f.find('input[name='+bianHao_inputName+']');
		}
		if(mingCheng_inputName!=undefined&&mingCheng_inputName!=''&&mingCheng_inputName!=null){
			userName = f.find('input[name='+mingCheng_inputName+']');
		}
		
		userID.val('');
		userName.val('');
		share.removeData('form');
		share.removeData('userSelectDialog');
		d.dialog('close');
		userName.focus();
	}
</script>
<div class="easyui-panel"style="width:500px;height:200px;padding:0px;background-color: white;" data-options="fit:true,border:false">
	<div class="easyui-layout" data-options="fit:true,border:false">	
		<div data-options="region:'north',border:false" style="height:60px;overflow:hidden;">
			<form id="searchForm" >
			
				<div style="padding:15px; margin: 0px; ">
	               	<span class="title">人员姓名</span>
	               	<input id="selectInput" type="text" name="userName"  class="t_d"/>
	               	<span class="title blankSpace"><s:text name="组织机构"></s:text></span>
	               	<input type="text" name="zuZhiJGMC" class="t_d"/>
	               	
	               	<a id="" class="easyui-linkbutton blankSpace" href="javascript:void(0)" onclick="_search();"><s:text name="query"></s:text></a>&nbsp;&nbsp;
	               	<a id="" class="easyui-linkbutton" href="javascript:void(0)" onclick="cleanSearch();"><s:text name="清除"></s:text></a>
			 	</div>
			
				<!--<div>
					<table class="tableForm datagrid-toolbar" style="width: 100%;height: 100%; padding: 10px;" >
						<tr>
							<td><s:text name="userName"></s:text></td>
							<td><input name="userName" style="width:200px;" /></td>
							<td><s:text name="ZuZhi"></s:text></td>
							<td><input name="zuZhiJGMC" style="width:200px;" /></td>
							<td>&nbsp;</td>
							<td align="center">
								<a href="javascript:void(0);" class="easyui-linkbutton" onclick="_search();"><s:text name="query"></s:text></a>
								<a href="javascript:void(0);" class="easyui-linkbutton" onclick="cleanSearch();"><s:text name="cancel"></s:text></a>
							</td>
						</tr>
					</table>
				</div>
				-->
			</form>
		</div>
		<div data-options="region:'center',border:false" data-options="fit:true">
			<table id="datagrid"></table>
		</div>
		<!--<div data-options="region:'south',border:false" align="right" data-options="fit:true">
			<a href="javascript:void(0);" class="easyui-linkbutton" onclick="clean();"><s:text name="clean"></s:text></a>
			<a href="javascript:void(0);" class="easyui-linkbutton" onclick="select();"><s:text name="select"></s:text></a>
		</div>
	--></div>
</div>

